﻿using Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace WindowsFormsApp1.Task
{
    public class MainTask
    {
        CancellationTokenSource cts = new CancellationTokenSource();
        public void Run()
        {
            while (!cts.IsCancellationRequested)
            {
                try
                {
                    if (cts.IsCancellationRequested)
                    {
                        return;
                    }
                    else
                    {
                        //这里写具体方法

                    }
                }
                catch (Exception ex) 
                {
                    Log.Error(ex.Message);
                }
            }
        }
        public void Cancel()
        {
            cts.Cancel();
        }
    }
}
